var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');//日志管理

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

var app = express();

app.use(logger('dev'));//日志中间键配置代码
app.use(express.json());//解析json数据
app.use(express.urlencoded({ extended: false }));//解析表单post数据
app.use(cookieParser());//cookie中间件配置代码
app.use(express.static(path.join(__dirname, 'public')));//静态资源下载服务

app.use('/', indexRouter);
app.use('/users', usersRouter);

module.exports = app;
